<%inherit file='/base.mako' />
<%def name="title()">Dashboard</%def>
<%def name="stylesheets()">
${h.stylesheet_link_tag('dashboard')}
</%def>

  <h2>Project Dashboard</h2>
<h3>Active Projects</h3>
% for project in c.projects:
<div class="project" onclick="document.location.href='${h.url_for(controller='/project', action='select', project_id=project.id)}'">
<div class="top">
	<h3>${project.name|h}</h3>
	<%
	if project.delayed:
	    status_class = "bad"
	else:
	    status_class = "good"
	%>
	<span class="status ${status_class}">${project.status_code}</span>
</div>
<div class="bottom">
	<span class="contact">
		<span class="label">Contact:</span>
		${h.mail_to(project.contact.email, project.contact.username)}
	</span>
	<span class="info">
	    ${len(project.total_risks)} risks,
	    ${len(project.total_issues)} issues,
	    ${len(project.total_notes)} notes,
	    ${len(project.total_questions)} questions,
	    ${len(project.total_answers)} answers
		<br/>
		<% subprojects = project.delayed_subprojects %>
		% if subprojects:
              and ${len(subprojects)} delayed subprojects($''.join([h.link_to('%d&#160;' % i, 
                                                                        h.url_for(controller='/project', action='view', id=subproject.id), 
                                                                        title=subproject.name) for i, subproject in enumerate(subprojects)])})
		% endif
   </span>				
</div>
</div>
% endfor
<br/>
	
${h.link_to_function('new project', "toggle('new_project'); clr('ta_new_project');fcs('tf_desc'); return false;")}
    % if c.form_errors:
    <div id="new_project">
    % else:
	<div id="new_project" style="display: none;">
    % endif
        ${h.start_form(h.url_for(action='new_project'), id='form_new_project')}
			<table>
				<tr><td width="120"><b>Project Name:</b></td><td>${h.text_field('name', size=50, id='tf_desc')}</td></tr>
				<tr>
					<td><b>Contact:</b></td>
					<td>
					    ${h.select('contact_id', h.user_options(c.current_user.id))}
					</td>
				</tr>
				<tr>
					<td><b>Create Sub-projects</b></td>
					<td>${h.check_box('subprojects')}</td>
				</tr>
				<tr>
					<td colspan="2"><b>Project Description</b></td>
				</tr>
				<tr>
					<td colspan="2">
					${h.text_area('description', cols=72, rows=4)}
					</td>
				</tr>
			</table>
			${h.link_to_function('add', "submit('form_new_project'); return false")}
			${h.link_to_function('cancel', "toggle('new_project'); return false")}
		${h.end_form()}
	</div>
	
	<br/><br/>
	
	<h3>Archived Projects</h3>
	
	${h.link_to_function('show archived_projects', "toggle('archived_projects');toggle('show_archived');toggle('hide_archived'); return false")}
	${h.link_to_function('hide archived_projects', "toggle('archived_projects');toggle('show_archived');toggle('hide_archived'); return false", style='display:none;')}

	<div style="display: none" id="archived_projects">
	    % for project in c.archived_projects:
		<div class="project archived" onclick="document.location.href='${h.url_for(controller='/project', action='select', project_id=project.id)}'">
			<div class="top">
				<h3>${project.name|h}</h3
				<span class="status archived">Archived</span>
			</div>
		</div>
		% endfor
	</div>
